/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.piaohao.controller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import java.util.List;
import org.piaohao.model.Log;
import org.piaohao.util.string.JsonUtil;

/**
 *
 * @author piaohao
 */
public class LogController extends Controller {

    public static final String moduleName = "日志模块";

    public void list() {
        try {
            Integer start = getParaToInt("start");
            Integer limit = getParaToInt("limit");
            String orgId = (String) getSessionAttr("orgId");
            List<Log> logs = null;
             Long total=0L;
            if (orgId.equals("0")) {
                logs = Log.dao.find("select * from t_log limit ?,?", start, limit);
                total = Db.queryLong("select count(*) from t_log");
            } else {
                logs = Log.dao.find("select * from t_log where org_id=? limit ?,?", orgId, start, limit);
                total = Db.queryLong("select count(*) from t_log where org_id=?",orgId);
            }
            renderJson(JsonUtil.printGrid(total, logs));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
